package com.sf;

import cn.hutool.core.util.StrUtil;
import com.sf.entity.SfLicensePlateConfigParam;
import org.jetbrains.annotations.NotNull;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;

public class LicensePlates {
    public static void main(String[] args) {

        //家
       // String path = "D:\\system\\demo\\dache-test\\service-hi\\src\\main\\resources\\licensePlates.txt";  // 输入日志文件路径
        //公司
        String path ="C:\\Users\\hcf\\IdeaProjects\\dache-test\\service-hi\\src\\main\\resources\\";

        String inputFilePath =path + "licensePlates.txt";  // 输入日志文件路径

        String licensePath = path + "licensePlatesHead.txt";

        Set<String> licensePlates = getLicensePlates(inputFilePath);
        Set<String> licensePlates2 = getLicensePlates(licensePath);
        System.out.println("挂车:");
        System.out.println( "\""+StrUtil.join("\",\"",licensePlates)+ "\"");
        System.out.println("车头:");
        System.out.println( "\""+StrUtil.join("\",\"",licensePlates2)+ "\"");



    }

    @NotNull
    public static Set<String> getLicensePlates(String patch) {

        // 创建一个 List 来存储车牌
        Set<String> licensePlates = new HashSet<>();
        try (BufferedReader reader = new BufferedReader(new FileReader(patch))) {

            String line;
            StringBuilder currentLogEntry = new StringBuilder();

            while ((line = reader.readLine()) != null) {

                if (StrUtil.isBlank(StrUtil.trim(line))) {
                    continue;
                }
                licensePlates.add(StrUtil.trim(line));
                // 添加当前行到日志条目
               // currentLogEntry.append(line).append(System.lineSeparator());
            }


        } catch (IOException e) {
            e.printStackTrace();
        }
        return licensePlates;
    }


}